package com.dz.control;

import com.dz.bean.gquanxian;
import com.dz.dao.ggaunliMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class gquanxainControl {
    @Resource
    private ggaunliMapper ggaunliMapper;

    @GetMapping("getquanxian")
    @ResponseBody
    public List<gquanxian> getquanxian(){
        List<gquanxian> list= ggaunliMapper.selectAll();
        return list;
    }

    @GetMapping("deletequanxian")
    @ResponseBody
    public int deletequanxian(HttpServletRequest request){
        String ids=request.getParameter("id");
        Integer id=Integer.valueOf(ids);
        int list= ggaunliMapper.deletegquanxian(id);
        return list;
    }

    @GetMapping("insertquanxian")
    @ResponseBody
    public int insertquanxian(HttpServletRequest request){
        String guize=request.getParameter("guize");
        String qname=request.getParameter("kongzhi");
        String fenlei=request.getParameter("fangfa");

        gquanxian g1=new gquanxian();
        g1.setGuize(guize);
        g1.setFenlei(fenlei);
        g1.setQname(qname);

        int i= ggaunliMapper.quanxianinsert(g1);
        return i;
    }
}
